package com.zf.zffencheng.strategy.impl;

import com.zf.zffencheng.model.dto.AllDeviceDTO;
import com.zf.zffencheng.model.pojo.DeviceTemplate;
import com.zf.zffencheng.model.pojo.NtAllDevice;
import com.zf.zffencheng.model.vo.DeviceVo;
import com.zf.zffencheng.strategy.DeviceFactory;
import com.zf.zffencheng.strategy.DeviceStrategy;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * ClassName: PaiweiDeviceStaregy <br/>
 * Description:  <br/>
 * date: 2021/5/31 9:54<br/>
 *
 * @author william <br/>
 */
@Component
public class PaiweiDeviceStaregy implements DeviceStrategy {

    @Override
    public NtAllDevice save(AllDeviceDTO allDeviceDTO) {
        NtAllDevice ntAllDevice = new NtAllDevice();
        ntAllDevice.setRegionId(allDeviceDTO.getRegionId());
        ntAllDevice.setTenantId(allDeviceDTO.getTenantId());
        ntAllDevice.setPalaceId(allDeviceDTO.getPalaceId());
        //设备类型
        Integer deviceType = allDeviceDTO.getDeviceType();
        ntAllDevice.setDeviceType(deviceType);
        //设备编号
        String mac = allDeviceDTO.getMac();
        ntAllDevice.setDeviceSn(mac);
        //标签
        String label = allDeviceDTO.getLabel();
        ntAllDevice.setDeviceName(label);
        //代码
        String code = allDeviceDTO.getCode();
        ntAllDevice.setDeviceNo(code);

        ntAllDevice.setApiId(allDeviceDTO.getApiId());

        return ntAllDevice;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        DeviceFactory.DEVICE_HANDLER_SERVICE.put(PAIWEI, this);
    }
}
